﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using TeamTime.Classes;
using StillVoiceCommon;

namespace TeamTime
{
    public partial class MessageDetails : System.Web.UI.UserControl
    {
              
        public Int32 CompanyID
        {
            get
            {
                if (this.txtCompanyID.Text == "") this.txtCompanyID.Text = "0";
                return Convert.ToInt32(this.txtCompanyID.Text);
            }
            set
            {
                this.txtCompanyID.Text = value.ToString();
            }
        }
        public Int32 TaskID
        {
            get { return Convert.ToInt32(this.txtID.Text); }
            set
            {
                //this.txtID.Text = .ToString();
                LoadDetailsForm(value);
            }
        }

       

        public event System.EventHandler LoadDupClicked;
        private void TaskFormControl_LoadDupClicked(object sender, EventArgs e) { }
        public delegate void LoadDupClickEventHandler(object sender, EventArgs e);

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                TN5YProjects tn5yProjects = new TN5YProjects();
                
                StaffMembers staffMembers = new StaffMembers();
                

                
                this.lnkAddTime.Enabled = false;

            }
            

        }

       
        private void LoadDetailsForm(Int32 ID)
        {
            Task task = new Task();
            task.load(ID.ToString());
            TimeEntries timeEntry = new TimeEntries();
            Functions.populateFormControlsFromDataTableFields(task, this.pnlDetails);
            this.hypURL.NavigateUrl = task.Fields["URL"].ToString();
            this.hypURL.Text = task.Fields["URL"].ToString();
            if (hypURL != null)
            {
                this.lblURL.Visible = false;
            }
            


        }
       

       
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Select")
            {
                Response.Redirect("TimeEntriesForm.aspx?ID=" + e.CommandArgument.ToString());
            }
            //if (e.CommandName == "Add")
            //{

            //    Response.Redirect("TimeEntriesForm.aspx?addmode=" + e.CommandArgument.ToString());
            //}

        }

       

       

       

        protected void lnkLoadDup_Click(object sender, EventArgs e)
        {
            if (this.lnkLoadDup.Attributes["DupID"] != "")
            {
                LoadDetailsForm(Convert.ToInt32(this.lnkLoadDup.Attributes["DupID"]));
                this.lnkLoadDup.Visible = false;
            }

            if (this.LoadDupClicked != null)
                this.LoadDupClicked(sender, e);
        }

        //private void Save()
        //{


        //}

    }
}